﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;

namespace CPPEI.ETL.WebApi.IntegrityCheck
{
    [CPPEI.WebApi.AuthPostAction("IntegrityCheck", "CreateInstance", "1.0")]
    public class CreateInstanceAction : BaseAction<CreateInstanceParams, CreateInstanceResult>
    {
        protected override ActionResult<CreateInstanceResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            CreateInstanceParams opParams)
        {
            ServiceResult serResult = new SER.CreateService().CreateIntegrityCheckInstance(opParams.TaskId, opParams.IntegrityCheckId, opParams.ParameterNames, opParams.ParameterValues);
            if(serResult.IsSuccess)
            {
                CreateInstanceResult result = new CreateInstanceResult();
                return new ActionResult<CreateInstanceResult>(result);
            }
            else
            {
                return new ActionResult<CreateInstanceResult>(serResult.IsSuccess, serResult.ErrorCode, serResult.Message, null);
            }
        }
    }

    public class CreateInstanceParams
    {
        [Parameter]
        public Guid TaskId { get; set; }

        [Parameter]
        public Guid IntegrityCheckId { get; set; }

        /// <summary>
        /// 参数名称
        /// 格式:    P1,P2,P3
        /// </summary>
        [Parameter]
        public string ParameterNames { get; set; }

        /// <summary>
        /// 值
        /// 格式: v1,v2,v3
        /// </summary>
        [Parameter]
        public string ParameterValues { get; set; }
    }

    public class CreateInstanceResult
    {
    }
}
